package com.srit.recipes.common.parent;


import com.srit.recipes.dao.*;
import com.srit.recipes.entity.RecipesInfo;
import com.srit.recipes.entity.RecipesNutrition;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.stream.Collectors;

public class DaoInject {


    @Autowired
    public RecipesDao recipesDao;

    @Autowired
    public WeekRecipesDao weekRecipesDao;

    @Autowired
    public WeekRecipesDetailDao weekRecipesDetailDao;

    @Autowired
    public CodeInfoDao codeInfoDao;

    @Autowired
    protected ScyyInfoDao scyyInfoDao;

    @Autowired
    public RecipesNutritionDao recipesNutritionDao;

    @Autowired
    public NutritionStandardDao nutritionStandardDao;

    @Autowired
    public DailyRequireDao dailyRequireDao;

    @Autowired
    public UserDao userDao;

    @Autowired
    protected ProcurementDetailDao procurementDetailDao;

    @Autowired
    protected InventoryDao inventoryDao;

    @Autowired
    protected InventoryHisDao inventoryHisDao;

    @Autowired
    protected ScPriceDao scPriceDao;

    @Autowired
    protected MealStandardDao mealStandardDao;

    @Autowired
    protected IngredientDao ingredientDao;

    @Autowired
    protected EquipmentDao equipmentDao;

    protected Map<String, RecipesInfo> recipesInfoMap = new HashMap<>();
    protected Map<String, RecipesNutrition> recipesNutritionMap = new HashMap<>();


    @PostConstruct
    public void init() {
        recipesInfoMap.putAll(recipesDao.findAll().stream().collect(Collectors.toMap(RecipesInfo::getCpId, Function.identity())));

        recipesNutritionMap.putAll(recipesNutritionDao.findAll().stream().collect(Collectors.toMap(RecipesNutrition::getCpId, Function.identity())));
    }














}
